﻿using System;
using System.IO;
using Microsoft.Xna.Framework.Audio;

namespace Terraria.ModLoader.Audio
{
	// Token: 0x02000275 RID: 629
	public class MusicStreamingWAV : MusicStreaming
	{
		// Token: 0x060019EF RID: 6639 RVA: 0x000125B2 File Offset: 0x000107B2
		public MusicStreamingWAV(string path)
		{
			this.stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Write | FileShare.Delete);
			this.Setup();
		}

		// Token: 0x060019F0 RID: 6640 RVA: 0x000125CF File Offset: 0x000107CF
		public MusicStreamingWAV(Stream stream)
		{
			this.stream = stream;
			this.Setup();
		}

		// Token: 0x060019F1 RID: 6641 RVA: 0x00427024 File Offset: 0x00425224
		private void Setup()
		{
			BinaryReader binaryReader = new BinaryReader(this.stream);
			int num = binaryReader.ReadInt32();
			int num2 = binaryReader.ReadInt32();
			int num3 = binaryReader.ReadInt32();
			int num4 = binaryReader.ReadInt32();
			int num5 = binaryReader.ReadInt32();
			int num6 = (int)binaryReader.ReadInt16();
			int channels = (int)binaryReader.ReadInt16();
			int sampleRate = binaryReader.ReadInt32();
			int num7 = binaryReader.ReadInt32();
			int num8 = (int)binaryReader.ReadInt16();
			int num9 = (int)binaryReader.ReadInt16();
			if (num5 == 18)
			{
				int count = (int)binaryReader.ReadInt16();
				binaryReader.ReadBytes(count);
			}
			int num10 = binaryReader.ReadInt32();
			int num11 = binaryReader.ReadInt32();
			this.dataStart = binaryReader.BaseStream.Position;
			this.stream.Position = this.dataStart;
			this.instance = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels);
		}
	}
}
